home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Games / Doom / ADoom-0.8 / ADoom_src / r_segs.c < prev    next >
C/C++ Source or Header  |  1998-06-24  |  17KB  |  759 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //    All the clipping: columns, horizontal spans, sky columns.
  21. //
  22. //-----------------------------------------------------------------------------
  23.  
  24.  
  25. static const char
  26. rcsid[] = "$Id: r_segs.c,v 1.3 1997/01/29 20:10:19 b1 Exp $";
  27.  
  28.  
  29.  
  30.  
  31.  
  32. #include <stdlib.h>
  33.  
  34. #include "i_system.h"
  35.  
  36. #include "doomdef.h"
  37. #include "doomstat.h"
  38.  
  39. #include "r_local.h"
  40. #include "r_sky.h"
  41.  
  42.  
  43. // OPTIMIZE: closed two sided lines as single sided
  44.  
  45. // True if any of the segs textures might be visible.
  46. boolean        segtextured;    
  47.  
  48. // False if the back side is the same plane.
  49. boolean        markfloor;    
  50. boolean        markceiling;
  51.  
  52. boolean        maskedtexture;
  53. int        toptexture;
  54. int        bottomtexture;
  55. int        midtexture;
  56.  
  57.  
  58. angle_t        rw_normalangle;
  59. // angle to line origin
  60. int        rw_angle1;    
  61.  
  62. //
  63. // regular wall
  64. //
  65. int        rw_x;
  66. int        rw_stopx;
  67. angle_t        rw_centerangle;
  68. fixed_t        rw_offset;
  69. fixed_t        rw_distance;
  70. fixed_t        rw_scale;
  71. fixed_t        rw_scalestep;
  72. fixed_t        rw_midtexturemid;
  73. fixed_t        rw_toptexturemid;
  74. fixed_t        rw_bottomtexturemid;
  75.  
  76. int        worldtop;
  77. int        worldbottom;
  78. int        worldhigh;
  79. int        worldlow;
  80.  
  81. fixed_t        pixhigh;
  82. fixed_t        pixlow;
  83. fixed_t        pixhighstep;
  84. fixed_t        pixlowstep;
  85.  
  86. fixed_t        topfrac;
  87. fixed_t        topstep;
  88.  
  89. fixed_t        bottomfrac;
  90. fixed_t        bottomstep;
  91.  
  92.  
  93. lighttable_t**    walllights;
  94.  
  95. short*        maskedtexturecol;
  96.  
  97.  
  98.  
  99. //
  100. // R_RenderMaskedSegRange
  101. //
  102. void
  103. R_RenderMaskedSegRange
  104. ( drawseg_t*    ds,
  105.   int        x1,
  106.   int        x2 )
  107. {
  108.     unsigned    index;
  109.     column_t*    col;
  110.     int        lightnum;
  111.     int        texnum;
  112.     
  113.     // Calculate light table.
  114.     // Use different light tables
  115.     //   for horizontal / vertical / diagonal. Diagonal?
  116.     // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
  117.     curline = ds->curline;
  118.     frontsector = curline->frontsector;
  119.     backsector = curline->backsector;
  120.     texnum = texturetranslation[curline->sidedef->midtexture];
  121.     
  122.     lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;
  123.  
  124.     if (curline->v1->y == curline->v2->y)
  125.     lightnum--;
  126.     else if (curline->v1->x == curline->v2->x)
  127.     lightnum++;
  128.  
  129.     if (lightnum < 0)        
  130.     walllights = scalelight[0];
  131.     else if (lightnum >= LIGHTLEVELS)
  132.     walllights = scalelight[LIGHTLEVELS-1];
  133.     else
  134.     walllights = scalelight[lightnum];
  135.  
  136.     maskedtexturecol = ds->maskedtexturecol;
  137.  
  138.     rw_scalestep = ds->scalestep;        
  139.     spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
  140.     mfloorclip = ds->sprbottomclip;
  141.     mceilingclip = ds->sprtopclip;
  142.     
  143.     // find positioning
  144.     if (curline->linedef->flags & ML_DONTPEGBOTTOM)
  145.     {
  146.     dc_texturemid = frontsector->floorheight > backsector->floorheight
  147.         ? frontsector->floorheight : backsector->floorheight;
  148.     dc_texturemid = dc_texturemid + textureheight[texnum] - viewz;
  149.     }
  150.     else
  151.     {
  152.     dc_texturemid =frontsector->ceilingheight<backsector->ceilingheight
  153.         ? frontsector->ceilingheight : backsector->ceilingheight;
  154.     dc_texturemid = dc_texturemid - viewz;
  155.     }
  156.     dc_texturemid += curline->sidedef->rowoffset;
  157.             
  158.     if (fixedcolormap)
  159.     dc_colormap = fixedcolormap;
  160.     
  161.     // draw the columns
  162.     for (dc_x = x1 ; dc_x <= x2 ; dc_x++)
  163.     {
  164.     // calculate lighting
  165.     if (maskedtexturecol[dc_x] != MAXSHORT)
  166.     {
  167.         if (!fixedcolormap)
  168.         {
  169.         index = spryscale>>LIGHTSCALESHIFT;
  170.  
  171.         if (index >=  MAXLIGHTSCALE )
  172.             index = MAXLIGHTSCALE-1;
  173.  
  174.         dc_colormap = walllights[index];
  175.         }
  176.             
  177.         sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale);
  178.         dc_iscale = 0xffffffffu / (unsigned)spryscale;
  179.         
  180.         // draw the texture
  181.         col = (column_t *)( 
  182.         (byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3);
  183.             
  184. //#ifndef AMIGA
  185.         R_DrawMaskedColumn (col);
  186. //#else
  187. //        R_DrawMaskedColumnAmi (col, TYPE_NORMAL);
  188. //#endif
  189.         maskedtexturecol[dc_x] = MAXSHORT;
  190.     }
  191.     spryscale += rw_scalestep;
  192.     }
  193.     
  194. }
  195.  
  196.  
  197.  
  198.  
  199. #ifdef AMIGA
  200.  
  201. extern void R_RenderSegLoop (void);
  202.  
  203. #else
  204. //
  205. // R_RenderSegLoop
  206. // Draws zero, one, or two textures (and possibly a masked
  207. //  texture) for walls.
  208. // Can draw or mark the starting pixel of floor and ceiling
  209. //  textures.
  210. // CALLED: CORE LOOPING ROUTINE.
  211. //
  212. #define HEIGHTBITS        12
  213. #define HEIGHTUNIT        (1<<HEIGHTBITS)
  214.  
  215. void R_RenderSegLoop (void)
  216. {
  217.     angle_t        angle;
  218.     unsigned        index;
  219.     int            yl;
  220.     int            yh;
  221.     int            mid;
  222.     fixed_t        texturecolumn;
  223.     int            top;
  224.     int            bottom;
  225.  
  226.     //texturecolumn = 0;                // shut up compiler warning
  227.  
  228.     for ( ; rw_x < rw_stopx ; rw_x++)
  229.     {
  230.     // mark floor / ceiling areas
  231.     yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
  232.  
  233.     // no space above wall?
  234.     if (yl < ceilingclip[rw_x]+1)
  235.         yl = ceilingclip[rw_x]+1;
  236.     
  237.     if (markceiling)
  238.     {
  239.         top = ceilingclip[rw_x]+1;
  240.         bottom = yl-1;
  241.  
  242.         if (bottom >= floorclip[rw_x])
  243.         bottom = floorclip[rw_x]-1;
  244.  
  245.         if (top <= bottom)
  246.         {
  247.         ceilingplane->top[rw_x] = top;
  248.         ceilingplane->bottom[rw_x] = bottom;
  249.         }
  250.     }
  251.         
  252.     yh = bottomfrac>>HEIGHTBITS;
  253.  
  254.     if (yh >= floorclip[rw_x])
  255.         yh = floorclip[rw_x]-1;
  256.  
  257.     if (markfloor)
  258.     {
  259.         top = yh+1;
  260.         bottom = floorclip[rw_x]-1;
  261.         if (top <= ceilingclip[rw_x])
  262.         top = ceilingclip[rw_x]+1;
  263.         if (top <= bottom)
  264.         {
  265.         floorplane->top[rw_x] = top;
  266.         floorplane->bottom[rw_x] = bottom;
  267.         }
  268.     }
  269.     
  270.     // texturecolumn and lighting are independent of wall tiers
  271.     if (segtextured)
  272.     {
  273.         // calculate texture offset
  274.         angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
  275.         texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance);
  276.         texturecolumn >>= FRACBITS;
  277.         // calculate lighting
  278.         index = rw_scale>>LIGHTSCALESHIFT;
  279.  
  280.         if (index >=  MAXLIGHTSCALE )
  281.         index = MAXLIGHTSCALE-1;
  282.  
  283.         dc_colormap = walllights[index];
  284.         dc_x = rw_x;
  285.         dc_iscale = 0xffffffffu / (unsigned)rw_scale;
  286.     }
  287.     
  288.     // draw the wall tiers
  289.     if (midtexture)
  290.     {
  291.         // single sided line
  292.         dc_yl = yl;
  293.         dc_yh = yh;
  294.         dc_texturemid = rw_midtexturemid;
  295.         dc_source = R_GetColumn(midtexture,texturecolumn);
  296.         colfunc ();
  297.         ceilingclip[rw_x] = viewheight;
  298.         floorclip[rw_x] = -1;
  299.     }
  300.     else
  301.     {
  302.         // two sided line
  303.         if (toptexture)
  304.         {
  305.         // top wall
  306.         mid = pixhigh>>HEIGHTBITS;
  307.         pixhigh += pixhighstep;
  308.  
  309.         if (mid >= floorclip[rw_x])
  310.             mid = floorclip[rw_x]-1;
  311.  
  312.         if (mid >= yl)
  313.         {
  314.             dc_yl = yl;
  315.             dc_yh = mid;
  316.             dc_texturemid = rw_toptexturemid;
  317.             dc_source = R_GetColumn(toptexture,texturecolumn);
  318.             colfunc ();
  319.             ceilingclip[rw_x] = mid;
  320.         }
  321.         else
  322.             ceilingclip[rw_x] = yl-1;
  323.         }
  324.         else
  325.         {
  326.         // no top wall
  327.         if (markceiling)
  328.             ceilingclip[rw_x] = yl-1;
  329.         }
  330.             
  331.         if (bottomtexture)
  332.         {
  333.         // bottom wall
  334.         mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
  335.         pixlow += pixlowstep;
  336.  
  337.         // no space above wall?
  338.         if (mid <= ceilingclip[rw_x])
  339.             mid = ceilingclip[rw_x]+1;
  340.         
  341.         if (mid <= yh)
  342.         {
  343.             dc_yl = mid;
  344.             dc_yh = yh;
  345.             dc_texturemid = rw_bottomtexturemid;
  346.             dc_source = R_GetColumn(bottomtexture,
  347.                         texturecolumn);
  348.             colfunc ();
  349.             floorclip[rw_x] = mid;
  350.         }
  351.         else
  352.             floorclip[rw_x] = yh+1;
  353.         }
  354.         else
  355.         {
  356.         // no bottom wall
  357.         if (markfloor)
  358.             floorclip[rw_x] = yh+1;
  359.         }
  360.             
  361.         if (maskedtexture)
  362.         {
  363.         // save texturecol
  364.         //  for backdrawing of masked mid texture
  365.         maskedtexturecol[rw_x] = texturecolumn;
  366.         }
  367.     }
  368.         
  369.     rw_scale += rw_scalestep;
  370.     topfrac += topstep;
  371.     bottomfrac += bottomstep;
  372.  
  373.     }
  374. }
  375. #endif
  376.  
  377.  
  378.  
  379.  
  380. //
  381. // R_StoreWallRange
  382. // A wall segment will be drawn
  383. //  between start and stop pixels (inclusive).
  384. //
  385. void
  386. R_StoreWallRange
  387. ( int    start,
  388.   int    stop )
  389. {
  390.     fixed_t        hyp;
  391.     fixed_t        sineval;
  392.     angle_t        distangle, offsetangle;
  393.     fixed_t        vtop;
  394.     int            lightnum;
  395.  
  396.     // don't overflow and crash
  397.     if (ds_p == &drawsegs[MAXDRAWSEGS])
  398.     return;        
  399.         
  400. #ifdef RANGECHECK
  401.     if (start >=viewwidth || start > stop)
  402.     I_Error ("Bad R_RenderWallRange: %i to %i", start , stop);
  403. #endif
  404.     
  405.     sidedef = curline->sidedef;
  406.     linedef = curline->linedef;
  407.  
  408.     // mark the segment as visible for auto map
  409.     linedef->flags |= ML_MAPPED;
  410.     
  411.     // calculate rw_distance for scale calculation
  412.     rw_normalangle = curline->angle + ANG90;
  413.     offsetangle = iabs(rw_normalangle-rw_angle1);
  414.     
  415.     if (offsetangle > ANG90)
  416.     offsetangle = ANG90;
  417.  
  418.     distangle = ANG90 - offsetangle;
  419.     hyp = R_PointToDist (curline->v1->x, curline->v1->y);
  420.     sineval = finesine[distangle>>ANGLETOFINESHIFT];
  421.     rw_distance = FixedMul (hyp, sineval);
  422.         
  423.     
  424.     ds_p->x1 = rw_x = start;
  425.     ds_p->x2 = stop;
  426.     ds_p->curline = curline;
  427.     rw_stopx = stop+1;
  428.     
  429.     // calculate scale at both ends and step
  430.     ds_p->scale1 = rw_scale = 
  431.     R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]);
  432.     
  433.     if (stop > start )
  434.     {
  435.     ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]);
  436.     ds_p->scalestep = rw_scalestep = 
  437.         (ds_p->scale2 - rw_scale) / (stop-start);
  438.     }
  439.     else
  440.     {
  441.     // UNUSED: try to fix the stretched line bug
  442. #if 0
  443.     if (rw_distance < FRACUNIT/2)
  444.     {
  445.         fixed_t        trx,try;
  446.         fixed_t        gxt,gyt;
  447.  
  448.         trx = curline->v1->x - viewx;
  449.         try = curline->v1->y - viewy;
  450.             
  451.         gxt = FixedMul(trx,viewcos); 
  452.         gyt = -FixedMul(try,viewsin); 
  453.         ds_p->scale1 = FixedDiv(projection, gxt-gyt)<<detailshift;
  454.     }
  455. #endif
  456.     ds_p->scale2 = ds_p->scale1;
  457.     }
  458.     
  459.     // calculate texture boundaries
  460.     //  and decide if floor / ceiling marks are needed
  461.     worldtop = frontsector->ceilingheight - viewz;
  462.     worldbottom = frontsector->floorheight - viewz;
  463.     
  464.     midtexture = toptexture = bottomtexture = maskedtexture = 0;
  465.     ds_p->maskedtexturecol = NULL;
  466.     
  467.     if (!backsector)
  468.     {
  469.     // single sided line
  470.     midtexture = texturetranslation[sidedef->midtexture];
  471.     // a single sided line is terminal, so it must mark ends
  472.     markfloor = markceiling = true;
  473.     if (linedef->flags & ML_DONTPEGBOTTOM)
  474.     {
  475.         vtop = frontsector->floorheight +
  476.         textureheight[sidedef->midtexture];
  477.         // bottom of texture at bottom
  478.         rw_midtexturemid = vtop - viewz;    
  479.     }
  480.     else
  481.     {
  482.         // top of texture at top
  483.         rw_midtexturemid = worldtop;
  484.     }
  485.     rw_midtexturemid += sidedef->rowoffset;
  486.  
  487.     ds_p->silhouette = SIL_BOTH;
  488.     ds_p->sprtopclip = screenheightarray;
  489.     ds_p->sprbottomclip = negonearray;
  490.     ds_p->bsilheight = MAXINT;
  491.     ds_p->tsilheight = MININT;
  492.     }
  493.     else
  494.     {
  495.     // two sided line
  496.     ds_p->sprtopclip = ds_p->sprbottomclip = NULL;
  497.     ds_p->silhouette = 0;
  498.     
  499.     if (frontsector->floorheight > backsector->floorheight)
  500.     {
  501.         ds_p->silhouette = SIL_BOTTOM;
  502.         ds_p->bsilheight = frontsector->floorheight;
  503.     }
  504.     else if (backsector->floorheight > viewz)
  505.     {
  506.         ds_p->silhouette = SIL_BOTTOM;
  507.         ds_p->bsilheight = MAXINT;
  508.         // ds_p->sprbottomclip = negonearray;
  509.     }
  510.     
  511.     if (frontsector->ceilingheight < backsector->ceilingheight)
  512.     {
  513.         ds_p->silhouette |= SIL_TOP;
  514.         ds_p->tsilheight = frontsector->ceilingheight;
  515.     }
  516.     else if (backsector->ceilingheight < viewz)
  517.     {
  518.         ds_p->silhouette |= SIL_TOP;
  519.         ds_p->tsilheight = MININT;
  520.         // ds_p->sprtopclip = screenheightarray;
  521.     }
  522.         
  523.     if (backsector->ceilingheight <= frontsector->floorheight)
  524.     {
  525.         ds_p->sprbottomclip = negonearray;
  526.         ds_p->bsilheight = MAXINT;
  527.         ds_p->silhouette |= SIL_BOTTOM;
  528.     }
  529.     
  530.     if (backsector->floorheight >= frontsector->ceilingheight)
  531.     {
  532.         ds_p->sprtopclip = screenheightarray;
  533.         ds_p->tsilheight = MININT;
  534.         ds_p->silhouette |= SIL_TOP;
  535.     }
  536.     
  537.     worldhigh = backsector->ceilingheight - viewz;
  538.     worldlow = backsector->floorheight - viewz;
  539.         
  540.     // hack to allow height changes in outdoor areas
  541.     if (frontsector->ceilingpic == skyflatnum 
  542.         && backsector->ceilingpic == skyflatnum)
  543.     {
  544.         worldtop = worldhigh;
  545.     }
  546.     
  547.             
  548.     if (worldlow != worldbottom 
  549.         || backsector->floorpic != frontsector->floorpic
  550.         || backsector->lightlevel != frontsector->lightlevel)
  551.     {
  552.         markfloor = true;
  553.     }
  554.     else
  555.     {
  556.         // same plane on both sides
  557.         markfloor = false;
  558.     }
  559.     
  560.             
  561.     if (worldhigh != worldtop 
  562.         || backsector->ceilingpic != frontsector->ceilingpic
  563.         || backsector->lightlevel != frontsector->lightlevel)
  564.     {
  565.         markceiling = true;
  566.     }
  567.     else
  568.     {
  569.         // same plane on both sides
  570.         markceiling = false;
  571.     }
  572.     
  573.     if (backsector->ceilingheight <= frontsector->floorheight
  574.         || backsector->floorheight >= frontsector->ceilingheight)
  575.     {
  576.         // closed door
  577.         markceiling = markfloor = true;
  578.     }
  579.     
  580.  
  581.     if (worldhigh < worldtop)
  582.     {
  583.         // top texture
  584.         toptexture = texturetranslation[sidedef->toptexture];
  585.         if (linedef->flags & ML_DONTPEGTOP)
  586.         {
  587.         // top of texture at top
  588.         rw_toptexturemid = worldtop;
  589.         }
  590.         else
  591.         {
  592.         vtop =
  593.             backsector->ceilingheight
  594.             + textureheight[sidedef->toptexture];
  595.         
  596.         // bottom of texture
  597.         rw_toptexturemid = vtop - viewz;    
  598.         }
  599.     }
  600.     if (worldlow > worldbottom)
  601.     {
  602.         // bottom texture
  603.         bottomtexture = texturetranslation[sidedef->bottomtexture];
  604.  
  605.         if (linedef->flags & ML_DONTPEGBOTTOM )
  606.         {
  607.         // bottom of texture at bottom
  608.         // top of texture at top
  609.         rw_bottomtexturemid = worldtop;
  610.         }
  611.         else    // top of texture at top
  612.         rw_bottomtexturemid = worldlow;
  613.     }
  614.     rw_toptexturemid += sidedef->rowoffset;
  615.     rw_bottomtexturemid += sidedef->rowoffset;
  616.     
  617.     // allocate space for masked texture tables
  618.     if (sidedef->midtexture)
  619.     {
  620.         // masked midtexture
  621.         maskedtexture = true;
  622.         ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x;
  623.         lastopening += rw_stopx - rw_x;
  624.     }
  625.     }
  626.     
  627.     // calculate rw_offset (only needed for textured lines)
  628.     segtextured = midtexture | toptexture | bottomtexture | maskedtexture;
  629.  
  630.     if (segtextured)
  631.     {
  632.     offsetangle = rw_normalangle-rw_angle1;
  633.     
  634.     if (offsetangle > ANG180)
  635.         offsetangle = -offsetangle;
  636.  
  637.     if (offsetangle > ANG90)
  638.         offsetangle = ANG90;
  639.  
  640.     sineval = finesine[offsetangle >>ANGLETOFINESHIFT];
  641.     rw_offset = FixedMul (hyp, sineval);
  642.  
  643.     if (rw_normalangle-rw_angle1 < ANG180)
  644.         rw_offset = -rw_offset;
  645.  
  646.     rw_offset += sidedef->textureoffset + curline->offset;
  647.     rw_centerangle = ANG90 + viewangle - rw_normalangle;
  648.     
  649.     // calculate light table
  650.     //  use different light tables
  651.     //  for horizontal / vertical / diagonal
  652.     // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
  653.     if (!fixedcolormap)
  654.     {
  655.         lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;
  656.  
  657.         if (curline->v1->y == curline->v2->y)
  658.         lightnum--;
  659.         else if (curline->v1->x == curline->v2->x)
  660.         lightnum++;
  661.  
  662.         if (lightnum < 0)        
  663.         walllights = scalelight[0];
  664.         else if (lightnum >= LIGHTLEVELS)
  665.         walllights = scalelight[LIGHTLEVELS-1];
  666.         else
  667.         walllights = scalelight[lightnum];
  668.     }
  669.     }
  670.     
  671.     // if a floor / ceiling plane is on the wrong side
  672.     //  of the view plane, it is definitely invisible
  673.     //  and doesn't need to be marked.
  674.     
  675.   
  676.     if (frontsector->floorheight >= viewz)
  677.     {
  678.     // above view plane
  679.     markfloor = false;
  680.     }
  681.     
  682.     if (frontsector->ceilingheight <= viewz 
  683.     && frontsector->ceilingpic != skyflatnum)
  684.     {
  685.     // below view plane
  686.     markceiling = false;
  687.     }
  688.  
  689.     
  690.     // calculate incremental stepping values for texture edges
  691.     worldtop >>= 4;
  692.     worldbottom >>= 4;
  693.     
  694.     topstep = -FixedMul (rw_scalestep, worldtop);
  695.     topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
  696.  
  697.     bottomstep = -FixedMul (rw_scalestep,worldbottom);
  698.     bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
  699.     
  700.  
  701.     if (backsector)
  702.     {    
  703.     worldhigh >>= 4;
  704.     worldlow >>= 4;
  705.  
  706.     if (worldhigh < worldtop)
  707.     {
  708.         pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
  709.         pixhighstep = -FixedMul (rw_scalestep,worldhigh);
  710.     }
  711.     
  712.     if (worldlow > worldbottom)
  713.     {
  714.         pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
  715.         pixlowstep = -FixedMul (rw_scalestep,worldlow);
  716.     }
  717.     }
  718.     
  719.     // render it
  720.     if (markceiling)
  721.     ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
  722.     
  723.     if (markfloor)
  724.     floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
  725.  
  726.     R_RenderSegLoop ();
  727.  
  728.     
  729.     // save sprite clipping info
  730.     if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture)
  731.      && !ds_p->sprtopclip)
  732.     {
  733.     memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start));
  734.     ds_p->sprtopclip = lastopening - start;
  735.     lastopening += rw_stopx - start;
  736.     }
  737.     
  738.     if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture)
  739.      && !ds_p->sprbottomclip)
  740.     {
  741.     memcpy (lastopening, floorclip+start, 2*(rw_stopx-start));
  742.     ds_p->sprbottomclip = lastopening - start;
  743.     lastopening += rw_stopx - start;    
  744.     }
  745.  
  746.     if (maskedtexture && !(ds_p->silhouette&SIL_TOP))
  747.     {
  748.     ds_p->silhouette |= SIL_TOP;
  749.     ds_p->tsilheight = MININT;
  750.     }
  751.     if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM))
  752.     {
  753.     ds_p->silhouette |= SIL_BOTTOM;
  754.     ds_p->bsilheight = MAXINT;
  755.     }
  756.     ds_p++;
  757. }
  758.  
  759.